<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/taglibs.jsp" %>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="${ctx}/resources/semanticui/semantic.min.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx}/resources/apps.css" rel="stylesheet" type="text/css"/>
    <title>订单详情</title>
</head>
<body>
<div class="ui segment" id="n-page">
    <h4 class="ui horizontal divider header">
        <i class="tag icon"></i>
        订单信息
    </h4>
    <table class="ui definition table">
        <tbody>
        <tr>
            <td class="two wide column">订单编号</td>
            <td><a href="${ctx}/wechat/hunter/toOrderDetail.do?orderId=${order.id}">YQS${order.ordercode}</a></td>
        </tr>
        <tr>
            <td class="two wide column">订单状态</td>
            <td><span style="color:#F47e2d;font-weight:bold;">${order.statusName}</span>
                <c:if test="${order.status==0}">
                    <button class="ui button active" id="accept" data-position-id="${order.id}"
                            style="float:right;background-color:#1fbad6!important;padding-top:0.7rem;padding-bottom:0.5rem;color:#fff">
                        接单
                    </button>
                    <button class="ui button active" id="refuse" data-position-id="${order.id}"
                            style="float:right;background-color:#1fbad6!important;padding-top:0.7rem;padding-bottom:0.5rem;color:#fff">
                        拒单
                    </button>
                </c:if>
            </td>
        </tr>
        <tr>
            <td>预约时间</td>
            <td>${order.orderTime}</td>
        </tr>
        <tr>
            <td>预约服务</td>
            <td>￥${desc.spec}/${desc.name}</td>
        </tr>
        <tr>
            <td>联系人</td>
            <c:choose>
                <c:when test="${order.status == 0 || order.status == 4 || order.status == 5}">
                    <td>接单之后可查看用户信息</td>
                </c:when>
                <c:otherwise>
                    <td>${(emp.phone).substring(0,7)}****<a
                            href="${ctx}/wechat/hunter/toViewCandidate.do?mobile=${emp.phone}">点击查看基础信息</a></td>
                </c:otherwise>
            </c:choose>
            </td>
        </tr>
        </tbody>
    </table>
    <div class="ui divider"></div>

    <c:choose>
    <c:when test="${order.status == 0 || order.status == 4 || order.status == 5}">
    <span style="text-align: center"><span style="text-align: center">以下是用户的简历，接单之后即可查看</span></span>
    </c:when>
    <c:otherwise>
    <h4 class="ui horizontal divider header">
        <i class="user circle outline icon"></i>
        用户完善的信息
    </h4>
    <div class="ui raised segment">
        <p>用户已将简历上传，您可以直接查看</p>
        <input type="hidden" name="employeeId" id="employeeId" value="${resume.employeeId}"/>
        <input type="hidden" name="hunterId" id="hunterId" value="${resume.hunterId}"/>
        <input type="hidden" name="ordescId" id="ordescId" value="${resume.ordescId}"/>
        <input type="hidden" name="orderId" id="orderId" value="${resume.orderId}"/>
        <input type="hidden" name="id" id="id" value="${resume.id}"/>
        <div class="ui placeholder segment">
            <div class="ui icon header">
                <i class="pdf file outline icon"></i>
                    ${resume.file}
            </div>
            <c:choose>
                <c:when test="${fn:contains(resume.file,'pdf')==true}">
                    <input type="hidden" value="${resume.file}" id="filepdf">
                    <a target="_blank" href="${ctx}/views/wechat/candidate/order/report.jsp?url=${resume.file}">
                        <div class="ui primary button">预览简历</div>
                    </a>
                </c:when>
                <c:when test="${fn:contains(resume.file,'docx')==true}">
                    <a target="_blank"
                       href="https://tiaonali.com/${(resume.file).substring(0,(resume.file).lastIndexOf('.'))}.html">
                        <div class="ui primary button">预览简历</div>
                    </a>
                </c:when>
                <c:otherwise>
                    <a target="_blank" href="https://tiaonali.com/${resume.file}">
                        <div class="ui primary button">预览简历</div>
                    </a>
                </c:otherwise>
            </c:choose>
        </div>
        <br/>
        <div class="ui segment" id="n-content">
            <div class="ui form">
                <div class="field">
                    <label>您意向的面试公司及职位（限对本次咨询）</label>
                    <p>${resume.intention}</p>
                </div>
                <div class="field">
                    <label>您更想了解该公司的哪些方面的信息</label>
                    <p>${resume.remark}</p>
                </div>
            </div>
        </div>
    </div>
    </c:otherwise>
    </c:choose>


    <script src="${ctx}/resources/jweixin-1.0.0.js"></script>
    <script src="${ctx}/resources/semanticui/jquery-2.1.4.min.js"></script>
    <script src="${ctx}/resources/semanticui/semantic.js"
            type="text/javascript"></script>
    <script type="text/javascript">
        /*
        wx.config({
            debug: false,
            appId: "${config.appid}",
    timestamp: ${config.currenttimestamp},  
    nonceStr: "${config.nonceStr}", 
    signature: "${config.signatureStr}", 
    jsApiList: ['checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage',
        'onMenuShareQQ',
        'onMenuShareWeibo',
        'showOptionMenu',
        'closeWindow']  
}); */

        var handler = {
            activate: function () {
                $(this).addClass('active').siblings().removeClass('active');

                if ($(this).attr('id') == 'closeit') {
                    wx.closeWindow();
                }

                if ($(this).attr('id') == 'accept') {
                    var orderId = $(this).attr('data-position-id');
                    console.log(orderId);
                    var postUrl = '${ctx}/wechat/hunter/updOrder.do';
                    $.ajax({
                        url: postUrl,
                        type: "POST",
                        data: {orderId: orderId, status: 1},
                        success: function (data, status) {
                            if (data.errorcode == 0) {
                                alert(data.msg);
                                location.reload()
                            } else {
                                alert(data.msg);
                                $(this).removeClass('disabled');
                            }
                        },
                        error: function () {
                            alert("服务出错，请稍后尝试");
                            $(this).removeClass('disabled');
                        }
                    });
                }
                if ($(this).attr('id') == 'refuse') {
                    var orderId = $(this).attr('data-position-id');
                    console.log(orderId);
                    var postUrl = '${ctx}/wechat/hunter/updOrder.do';
                    $.ajax({
                        url: postUrl,
                        type: "POST",
                        data: {orderId: orderId, status: 5},
                        success: function (data, status) {
                            if (data.errorcode == 0) {
                                alert(data.msg);
                                var forwardUrl = '${ctx}/wechat/hunter/toOrderDetail.do?orderId=' + orderId;
                                window.location.href = forwardUrl;
                            } else {
                                alert(data.msg);
                                $(this).removeClass('disabled');
                            }
                        },
                        error: function () {
                            alert("服务出错，请稍后尝试");
                            $(this).removeClass('disabled');
                        }
                    });
                }

            }
        };

        $(document).ready(function () {

            $('.button').on('click', handler.activate);
            wx.ready(function () {
                wx.onMenuShareAppMessage({
                    title: 'Headoffer--专业招聘平台----推荐有奖！',
                    desc: '搭起企业和专业猎头的桥梁，为企业招募英才。',
                    link: 'http://www.tiaonali.com${ctx}/wechat/hunter/shareservice.page',
                    imgUrl: 'http://www.tiaonali.com${ctx}/resources/images/sharelogo.jpg',
                    type: 'link'
                });

                wx.onMenuShareTimeline({
                    title: 'Headoffer--专业招聘平台----推荐有奖！',
                    desc: '搭起企业和专业猎头的桥梁，为企业招募英才。',
                    link: 'http://www.tiaonali.com${ctx}/wechat/hunter/shareservice.page',
                    imgUrl: 'http://www.tiaonali.com${ctx}/resources/images/sharelogo.jpg'
                });

                wx.showOptionMenu();
            });
        });
    </script>
</body>
</html>